﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace MapLibrary
{
    public class Layer
    {
        private List<MapNode> mLayerNodes;

        string nodesListAsset;

        public Layer()
        {
            mLayerNodes = new List<MapNode>();
        }

        public void Draw(SpriteBatch batch, WorldViewport Viewport)
        {
            foreach (MapNode node in mLayerNodes)
            {
                node.Draw(batch, Viewport);
            }
        }

        public void AddNode(MapNode Node)
        {
            mLayerNodes.Add(Node);
        }

        //[ContentSerializerIgnore]
        public List<MapNode> MapNodes
        {
            get { return mLayerNodes; }
        }

        public string NodesListAsset
        {
            get { return nodesListAsset; }
            set { nodesListAsset = value; }
        }

        public void LoadLayer(ContentManager Content)
        {
            mLayerNodes = Content.Load<List<MapNode>>(nodesListAsset);
        }
    }

    /*public class LayerContentReader : ContentTypeReader<Layer>
    {
        protected override Layer Read(ContentReader input, Layer existingInstance)
        {
            Layer layer;
            if (existingInstance != null)
                layer = existingInstance;
            else
                layer = new Layer();

            layer.NodesListAsset = input.ReadString();

            layer.LoadLayer(input.ContentManager);

            return layer;
        }
    }*/
}
